﻿using System;
using System.Collections.Generic;
using System.Data;

using CoreLab.Oracle; //using Devart.Data.Oracle; //using Oracle.DataAccess.Client; 
//using Oracle.DataAccess.Types;

using LMD.Constant;
using LMD.Lib.DataClass;
using LMD.Lib.Oracle;

namespace DBQuery
{
    /// <summary>
    /// Summary description for ContactPersonTable
    /// </summary>
    public static class ContactPersonTable
    {
        public static void SaveContactChanges(ContactInfoData ciData)
        {
            DBLib dbl = new DBLib();
            dbl.BeginTransaction();

            try
            {
                if (ciData.ID < 0)
                {
                    if (ciData.IsCPTeknis)
                    {
                        ciData.ID = DBQuery.ContactPersonTable.InsertNewContactPersonTeknis(dbl, ciData);
                    }
                    else
                    {
                        ciData.ID = DBQuery.ContactPersonTable.InsertNewContactPerson(dbl, ciData);
                    }
                }
                else
                {
                    if (ciData.IsNewCP)
                    {
                        DBQuery.ContactPersonTable.UpdateNewContactPerson(dbl, ciData);
                    }
                    else
                    {
                        DBQuery.ContactPersonTable.UpdateExistingContactPerson(dbl, ciData);
                    }
                }

                UpdateCustomData(dbl, ciData);

                dbl.EndTransaction(true);
            }
            catch (Exception ex)
            {
                dbl.EndTransaction(false);
                throw ex;
            }
        }

        public static void UpdateCustomData(DBLib dbl, ContactInfoData cidToUpdate)
        {
            Cached.ContactPersonTable ccContactPerson = new Cached.ContactPersonTable();
            ContactInfoData cidExisting = new ContactInfoData();
            cidExisting = ccContactPerson.GetContactInfoData(cidToUpdate.ID, cidToUpdate.IsNewCP, true);

            Dictionary<String, String> dicNew = cidToUpdate.GetCustomDataDictionary();
            Dictionary<String, String> dicExisting = cidExisting.GetCustomDataDictionary();

            List<String> lsChanged = new List<String>();
            String sxInfoName = String.Empty;
            Cached.ContactDataTypeTable ccInfo = new Cached.ContactDataTypeTable();
           
            foreach (KeyValuePair<String, String> item in dicNew)
            {

                int iInfoType = Convert.ToInt32(item.Key);
                sxInfoName = ccInfo.GetContactDataTypeName(iInfoType);

                if (dicExisting.ContainsKey(item.Key))
                {
                    // UPDATE
                    if (String.IsNullOrEmpty(item.Value))
                    {
                        DeleteContactData(dbl, cidToUpdate.ID, cidToUpdate.IsNewCP, iInfoType);
                        lsChanged.Add("Deleted " + sxInfoName + " data");
                    }
                    else
                    {
                        UpdateContactData(dbl, cidToUpdate.ID, cidToUpdate.IsNewCP, iInfoType, item.Value);
                        lsChanged.Add("Updated " + sxInfoName + ": " + item.Value);
                    }

                    dicExisting.Remove(item.Key);
                }
                else
                {
                    // INSERT
                    InsertContactData(dbl, cidToUpdate.ID, cidToUpdate.IsNewCP, iInfoType, item.Value);
                    lsChanged.Add("Added " + sxInfoName + ": " + item.Value);

                    String x = "1";
                    int y = int.Parse(x);
                }
            }

            foreach (KeyValuePair<String, String> item in dicExisting)
            {
                // DELETE YG SUDAH TIDAK ADA LAGI
                int iInfoType = Convert.ToInt32(item.Key);
                DeleteContactData(dbl, cidToUpdate.ID, cidToUpdate.IsNewCP, iInfoType);
                
                sxInfoName = ccInfo.GetContactDataTypeName(iInfoType);
                lsChanged.Add("Deleted " + sxInfoName + " data");
            }

            CreateNewsFeed(dbl, cidToUpdate, lsChanged);
        }

        private static void CreateNewsFeed(DBLib dbl, ContactInfoData cid, List<String> lsChanged)
        {
            lsChanged.Sort();

            NewsFeedData nfd = new NewsFeedData();
            nfd.iCustomerId = cid.CompanyID;
            nfd.iSourceId = (int)NewsFeedSourceType.ICP;
            nfd.sxUserId_Poster = ICPUser.ID;
            nfd.sxTitle = "Contact Person Data has been updated!";
            nfd.sxContent = "Contact Person Name: " + cid.sxContactName;
            foreach (String item in lsChanged)
            { 
                nfd.sxContent += "<br/>" + item;
            }

            if (nfd.sxContent.Length > 255)
            {
                nfd.sxContent = nfd.sxContent.Substring(0, 255);
            }

            DBQuery.NewsFeedTable.SaveNewsFeed(dbl, nfd);
        }

        public static int InsertNewContactPerson(ContactInfoData cid)
        {
            DBLib dbl = new DBLib();
            int iReturn = InsertNewContactPerson(dbl, cid);
            
            return iReturn;
        }
        public static int InsertNewContactPerson(DBLib dbl, ContactInfoData cid)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "out_new_id";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Output;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NAME";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxContactName;
            
            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_PHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxPhoneNumber;
            
            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_EMAIL";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxEmailAddress;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CUSTOMER_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.CompanyID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_GENDER";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.Sex == Gender.Male ? KGlobal.MALE : KGlobal.FEMALE;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CELLPHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxCellPhoneNumber;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_P_PIC_POSITION_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.JobPositionID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CREATE_BY";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "PR_INSERT_NEW_CONTACT_PERSON";

            dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());

            return Convert.ToInt32(lsParams[0].Value);
        }

        public static void DeleteNewContactPerson(int iNewCPId)
        {
            DBLib dbl = new DBLib();
            DeleteNewContactPerson(dbl, iNewCPId);
        }
        public static void DeleteNewContactPerson(DBLib dbl, int iNewCPId)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "prmID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = iNewCPId;

            String sxQuery = "delete from NEW_CONTACT_PERSON where NEW_CONTACT_PERSON_ID = :prmID";

            dbl.ExecuteNonQuery(sxQuery, lsParams.ToArray());
        }

        public static int InsertNewContactPersonTeknis(DBLib dbl, ContactInfoData cid)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "out_new_id";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Output;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NAME";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxContactName;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_PHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxPhoneNumber;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_EMAIL";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxEmailAddress;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CUSTOMER_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.CompanyID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_GENDER";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.Sex == Gender.Male ? KGlobal.MALE : KGlobal.FEMALE;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CELLPHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxCellPhoneNumber;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_P_PIC_POSITION_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.JobPositionID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CREATE_BY";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "pr_insert_NEW_CP_TEKNIS";

            dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());

            return Convert.ToInt32(lsParams[0].Value);
        }


        public static void UpdateNewContactPerson(ContactInfoData cid)
        {
            DBLib dbl = new DBLib();
            UpdateNewContactPerson(dbl, cid);
            
        }
        public static void UpdateNewContactPerson(DBLib dbl, ContactInfoData cid)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NEW_CONTACT_PERSON_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.ID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NAME";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxContactName;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_PHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxPhoneNumber;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_EMAIL";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxEmailAddress;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CUSTOMER_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.CompanyID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_GENDER";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.Sex == Gender.Male ? KGlobal.MALE : KGlobal.FEMALE;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CELLPHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxCellPhoneNumber;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_P_PIC_POSITION_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.JobPositionID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_UPDATE_BY";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "PR_UPDATE_NEW_CONTACT_PERSON";

            dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());
        }

        public static void UpdateExistingContactPerson(ContactInfoData cid)
        {
            DBLib dbl = new DBLib();
            UpdateExistingContactPerson(dbl, cid);
            
        }
        public static void UpdateExistingContactPerson(DBLib dbl, ContactInfoData cid)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_PIC_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.ID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NAME";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxContactName;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_PHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxPhoneNumber;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_EMAIL";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxEmailAddress;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_GENDER";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.Sex == Gender.Male ? KGlobal.MALE : KGlobal.FEMALE;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CELLPHONE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.sxCellPhoneNumber;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_IS_CP_TEKNIS";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = cid.IsCPTeknis ? KGlobal.YES : KGlobal.NO;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_P_PIC_POSITION_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = cid.JobPositionID;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_UPDATE_BY";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "PR_UPDATE_OLD_CONTACT_PERSON";

            dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());
        }

        public static int InsertContactData(int iContactId, bool IsNewCP, int iInfoTypeId, String sxValue)
        {
            DBLib dbl = new DBLib();
            int iReturn = InsertContactData(dbl, iContactId, IsNewCP, iInfoTypeId, sxValue);
            
            return iReturn;
        }
        public static int InsertContactData(DBLib dbl, int iContactId, bool IsNewCP, int iInfoTypeId, String sxValue)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "out_new_id";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Output;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_VALUE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = sxValue;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CONTACT_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            
            if (IsNewCP)
            {
                lsParams[lsParams.Count - 1].Value = DBNull.Value;
            }
            else
            {
                lsParams[lsParams.Count - 1].Value = iContactId; 
            }

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NEWCONTACT_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            
            if (IsNewCP)
            {
                lsParams[lsParams.Count - 1].Value = iContactId;
            }
            else
            {
                lsParams[lsParams.Count - 1].Value = DBNull.Value;
            }

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_P_CONTACT_DATA_TYPE_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = iInfoTypeId;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CREATE_BY";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "PR_INSERT_T_CONTACT_DATA";

            dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());

            return Convert.ToInt32(lsParams[0].Value);
        }

        public static void UpdateContactData(int iContactId, bool IsNewCP, int iInfoTypeId, String sxValue)
        {
            DBLib dbl = new DBLib();
            UpdateContactData(dbl, iContactId, IsNewCP, iInfoTypeId, sxValue);
            
        }
        public static void UpdateContactData(DBLib dbl, int iContactId, bool IsNewCP, int iInfoTypeId, String sxValue)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_VALUE";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = sxValue;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CONTACT_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;

            if (IsNewCP)
            {
                lsParams[lsParams.Count - 1].Value = DBNull.Value;
            }
            else
            {
                lsParams[lsParams.Count - 1].Value = iContactId;
            }

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NEWCONTACT_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;

            if (IsNewCP)
            {
                lsParams[lsParams.Count - 1].Value = iContactId;
            }
            else
            {
                lsParams[lsParams.Count - 1].Value = DBNull.Value;
            }

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_P_CONTACT_DATA_TYPE_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = iInfoTypeId;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_UPDATE_BY";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "PR_UPDATE_T_CONTACT_DATA";

            dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());
        }

        public static void DeleteContactData(int iContactId, bool IsNewCP, int iInfoTypeId)
        {
            DBLib dbl = new DBLib();
            DeleteContactData(dbl, iContactId, IsNewCP, iInfoTypeId);
            
        }
        public static void DeleteContactData(DBLib dbl, int iContactId, bool IsNewCP, int iInfoTypeId)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_CONTACT_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;

            if (IsNewCP)
            {
                lsParams[lsParams.Count - 1].Value = DBNull.Value;
            }
            else
            {
                lsParams[lsParams.Count - 1].Value = iContactId;
            }

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NEWCONTACT_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;

            if (IsNewCP)
            {
                lsParams[lsParams.Count - 1].Value = iContactId;
            }
            else
            {
                lsParams[lsParams.Count - 1].Value = DBNull.Value;
            }

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_P_CONTACT_DATA_TYPE_ID";
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = iInfoTypeId;

            String sxQuery = "PR_DELETE_T_CONTACT_DATA";

            dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());
        }
    }
}